/** \file simple_demo.ino
 * Demo program for the ezlcd3xx Arduino library.
 */

/*
 * Written and maintained by Sergey Butylkov. 
 * Created on behalf of EarthLCD.com a dba of Earth Computer Technologies Inc.
 *
 * Project home: http://arduino-ezlcd3xx.googlecode.com
 *
 * Copyright (C) 2012 Sergey Butylkov
 * Copyright (C) 2012 EarthLCD.com a dba of Earth Computer Technologies, Inc.
 * 
 * This work is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version. This work is distributed in the hope that it will be 
 * useful, but without any warranty; without even the implied warranty of 
 * merchantability or fitness for a particular purpose. See the GNU Lesser 
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include "ezlcd3xx.h"

#define LED_PIN 13

//EzLCD3xx_HW lcd; // uses pins 0 and 1
//EzLCD3xx_SW lcd( 10, 11 ); // arLCD users must use this
EzLCD3xx_SW lcd( 6, 7 );

void setup()
{
    lcd.begin( 9600 );
    lcd.fontw( 1, "sans24" );
    lcd.theme( 1, 9, 3, 0, 0, 0, 8, 8, 8, 1, 1 );
    lcd.theme( 2, 5, 20, 3, 3, 3, 4, 4, 4, 2, 1 );
    lcd.cls( 0 );
    lcd.string( 1, "ON" );
    lcd.string( 2, "OFF" );
    lcd.button( 1, 1, 1, 10, 40, 185, 140 );
    lcd.button( 2, 2, 2, 205, 40, 185, 140 );
	
    pinMode( LED_PIN, OUTPUT );
    digitalWrite( LED_PIN, LOW );
}

void loop()
{
#if EZLCD_SERIALDEBUG
    lcd.forwardSerial();
#endif
    if( lcd.pollLCD(1000L) )
    {
        if( lcd.wasReleased(1) )
            digitalWrite( LED_PIN, HIGH );
        else if( lcd.wasReleased(2) )
            digitalWrite( LED_PIN, LOW );
    }
}
